package com.rs.statistics.Controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.rs.statistics.dao.IReadroomDao;
import com.rs.statistics.model.Readroom;
import com.rs.statistics.service.IReadroomService;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/Readroom")
public class ReadroomController {
	@Resource
	private IReadroomDao readroomDao;
	@Resource
	private IReadroomService ReadroomService;
	
	@ApiOperation(value = "查询资源教室", notes = "查询所有资源")
	@PostMapping("findAll")
	public Map findAll(@RequestBody Readroom readroom){
		return ReadroomService.find(readroom);
	}
		@ApiOperation(value = "添加资源教室",notes = "添加资源教室")
		@PostMapping("/add")
		public String add(@RequestBody Readroom readroom) {
			readroomDao.save(readroom);
			return "添加成功";
			
		}
		@ApiOperation(value = "修改资源教室",notes = "修改资源教室")
		@PostMapping("update")
		public String update(@RequestBody Readroom readroom) {
			readroomDao.save(readroom);
			return "修改成功";
	
		}
		@ApiOperation(value = "删除资源教室",notes = "删除资源教室")
		@GetMapping("id")
		public String del(int id) {
			readroomDao.deleteById(id);
			return "删除成功";
	
		}
}
